import { api } from '@/utils/request'
import type { Bottle, CreateBottleRequest, UpdateBottleRequest } from '@/types/bottle'

// 获取所有漂流瓶
export const getBottles = () => {
  return api.get<Bottle[]>('/bottles')
}

// 随机获取一个漂流瓶
export const getRandomBottle = () => {
  return api.get<Bottle>('/bottles/random')
}

// 创建漂流瓶
export const createBottle = (data: CreateBottleRequest) => {
  return api.post<Bottle>('/bottles', data)
}

// 更新漂流瓶
export const updateBottle = (id: number, data: UpdateBottleRequest) => {
  return api.put<Bottle>(`/bottles/${id}`, data)
}

// 删除漂流瓶
export const deleteBottle = (id: number) => {
  return api.delete(`/bottles/${id}`)
}

// 获取已删除的漂流瓶（回收站）
export const getDeletedBottles = () => {
  return api.get<Bottle[]>('/bottles/deleted')
}

// 恢复漂流瓶
export const restoreBottle = (id: number) => {
  return api.put(`/bottles/${id}/restore`)
}

// 永久删除漂流瓶
export const permanentDeleteBottle = (id: number) => {
  return api.delete(`/bottles/${id}/permanent`)
}
